package com.black.web.controller.find;

import com.black.app.domain.find.AppFindZhangzhishiZan;
import com.black.app.domain.req.find.add.Zhangzhishizanaddreq;
import com.black.app.domain.req.find.query.AppFindZhangzhishidianzanreq;
import com.black.app.service.find.AppFindZhangzhishiZanService;
import com.black.common.core.controller.BaseController;
import com.black.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "后台--find-涨知识-点赞")
@RestController
@RequestMapping(value = "/admin/find/dianzan")
public class AdminFindZhangzhishidianzanController extends BaseController {

    @Autowired
    private AppFindZhangzhishiZanService appFindZhangzhishiZanService;

    @PreAuthorize("@ss.hasAppPermi()")
    @ApiOperation(value = "分页查询")
    @GetMapping(value = "/data")
    public R<PageInfo<AppFindZhangzhishiZan>> list(AppFindZhangzhishidianzanreq req){
        PageInfo<AppFindZhangzhishiZan> page = this.appFindZhangzhishiZanService.paginationQuery(req);
        return R.ok(page);
    }

    @PreAuthorize("@ss.hasAppPermi()")
    @ApiOperation(value = "新增")
    @PostMapping
    public R add(@RequestBody @Valid Zhangzhishizanaddreq req) {
        boolean result = this.appFindZhangzhishiZanService.add(req);
        return super.isSuccess(result);
    }

    @PreAuthorize("@ss.hasAppPermi()")
    @ApiOperation(value = "根据id删除")
    @DeleteMapping("/{ids}")
    public R deleteById(@PathVariable(value = "ids") Long[] ids) {
        boolean res = this.appFindZhangzhishiZanService.deletezanid(ids);
        return super.isSuccess(res);
    }


}
